package com.lmabbe.core.service.impls;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lmabbe.core.common.entitys.SysDic;
import com.lmabbe.core.common.entitys.SysDicItem;
import com.lmabbe.core.common.interfaces.SysDicService;
import com.lmabbe.core.common.query.SysDicItemQuery;
import com.lmabbe.core.common.query.SysDicQuery;
import com.lmabbe.core.service.dao.SysDicItemMapper;
import com.lmabbe.core.service.dao.SysDicMapper;
import lombok.RequiredArgsConstructor;
import org.apache.dubbo.config.annotation.DubboService;

/**
 * @author lmabbe
 */
@DubboService(provider = "simple-dubbo")
@RequiredArgsConstructor
public class SysDicServiceImpl extends ServiceImpl<SysDicMapper, SysDic> implements SysDicService {

    private final SysDicItemMapper sysDicItemMapper;

    @Override
    public IPage selectPage(SysDicQuery query) {
        return baseMapper.selectPage(query.createPage(), query.createQuery());
    }

    @Override
    public IPage<SysDicItem> items(Long dicId, SysDicItemQuery query) {
        return sysDicItemMapper.selectPage(query.createPage(), query.createQuery());
    }

    @Override
    public SysDicItem item(Long itemId) {
        return sysDicItemMapper.selectById(itemId);
    }

    @Override
    public void delItem(Long itemId) {
        sysDicItemMapper.deleteById(itemId);
    }

    @Override
    public void addItem(SysDicItem item) {
        sysDicItemMapper.insert(item);
    }

    @Override
    public void editItem(SysDicItem resource) {
        sysDicItemMapper.updateById(resource);
    }

}
